home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9796 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help !!!!! on 'strstr"
  5. Date: 13 Mar 1996 16:07:28 GMT
  6. Organization: Los Alamos National Laboratory
  7. Distribution: world
  8. Message-ID: <TANMOY.96Mar13090728@qcd.lanl.gov>
  9. References: <314703FF.4045@msmail.st.stems.com>
  10.     <Pine.A32.3.91.960312195354.119955C-100000@black.weeg.uiowa.edu>
  11. NNTP-Posting-Host: qcd.lanl.gov
  12. Mime-Version: 1.0
  13. Content-Type: text
  14. In-reply-to: The Amorphous Mass's message of Tue, 12 Mar 1996 19:57:12 -0600
  15.  
  16. In article <Pine.A32.3.91.960312195354.119955C-100000@black.weeg.uiowa.edu>
  17. The Amorphous Mass <robinson@blue.weeg.uiowa.edu> writes:
  18. <snip>
  19. TAM:   No, but you can write your own strstr() (case-sensitive) and then when 
  20. TAM: you have it working then change the character-to-character comparison 
  21. TAM: from, say c1 == c2 to toupper(c1) == toupper(c2).  I did this recently to 
  22. TAM: write a case-insensitive strncmp().  [tolower() will also work, of course].
  23. TAM:   toupper() and tolower() are in <ctype.h>.
  24.  
  25. Significant points to be mentioned: the function name should not start
  26. with str followed by lower case letter, and the c1 and c2 above must
  27. be unsigned chars.
  28.  
  29. On a side issue, is anybody aware of a real locale where, given
  30. unsigned chars c1 and c2,
  31.  
  32.  (toupper(c1) == toupper(c2)) || (tolower(c1) == tolower(c2))
  33.  
  34. is better than 
  35.  
  36.   toupper(c1) == toupper(c2)
  37.  
  38. ? (I am reasonably sure that I do not want to check whether
  39. toupper(tolower(x))'s match, but I always wondered about this one.)
  40.  
  41. Cheers
  42. Tanmoy
  43. --
  44. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  45. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  46. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  47. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  48. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  49. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  50.